package com.topisv.tms.utils.http;

import java.util.concurrent.LinkedBlockingQueue;

import com.topisv.tms.service.vo.invoice.InvoiceReturnModel;
import com.topisv.tms.utils.vo.PreInstorageVo;
import com.topisv.tms.utils.vo.WMSPrinter;

/**
 * 单例模式,消息暂存队列
 * 
 * @author Administrator
 * 
 */
public class SynchroShippedBatchQueue {

	private static int maxLength = 1000;

	private SynchroShippedBatchQueue() {
	}

	private static class Single {
		private static LinkedBlockingQueue<String> synchroQueue = new LinkedBlockingQueue<String>(maxLength);// 发货

		private static LinkedBlockingQueue<String> sendBatchQueue = new LinkedBlockingQueue<String>(maxLength);// 推送出库批次

		private static LinkedBlockingQueue<String> sendMessageQueue = new LinkedBlockingQueue<String>(maxLength);// jms消息队列

		private static LinkedBlockingQueue<WMSPrinter> wmsPrinterQueue = new LinkedBlockingQueue<WMSPrinter>(maxLength);// 修改打印状态的队列

		/**
		 * 入库预约邮件发送队列
		 */
		private static LinkedBlockingQueue<PreInstorageVo> PreBillMailQueue = new LinkedBlockingQueue<PreInstorageVo>(maxLength);
		/**
		 * 修改发票打印状态
		 */
		private static LinkedBlockingQueue<InvoiceReturnModel> InvoicePrinterQueue = new LinkedBlockingQueue<InvoiceReturnModel>(maxLength);

	}

	/**
	 * 生产产品
	 * 
	 * @param messages
	 */
	public static void putWmsPrinterQueue(WMSPrinter messages) {
		try {

			Single.wmsPrinterQueue.put(messages);
		} catch (InterruptedException e) {

		}
	}

	/**
	 * 消费产品
	 * 
	 * @param messages
	 */
	public static WMSPrinter takeWmsPrinterQueue() {
		try {
			return Single.wmsPrinterQueue.take();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block

		}
		return null;
	}

	/**
	 * 生产产品
	 * 
	 * @param messages
	 */
	public static void putSendMessageQueue(String messages) {
		try {

			Single.sendMessageQueue.put(messages);
		} catch (InterruptedException e) {

		}
	}

	/**
	 * 消费产品
	 * 
	 * @param messages
	 */
	public static String takeSendMessageQueue() {
		try {
			return Single.sendMessageQueue.take();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block

		}
		return null;
	}

	/**
	 * 生产产品
	 * 
	 * @param messages
	 */
	public static void putSendBatchQueue(String messages) {
		try {
			Single.sendBatchQueue.put(messages);
		} catch (InterruptedException e) {

		}
	}

	/**
	 * 消费产品
	 * 
	 * @param messages
	 */
	public static String takeSendBatchQueue() {
		try {
			return Single.sendBatchQueue.take();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block

		}
		return null;
	}

	/**
	 * 生产产品
	 * 
	 * @param messages
	 */
	public static void putSynchroQueue(String messages) {
		try {
			Single.synchroQueue.put(messages);
		} catch (InterruptedException e) {

		}
	}

	/**
	 * 消费产品
	 * 
	 * @param messages
	 */
	public static String takeSynchroQueue() {
		try {
			return Single.synchroQueue.take();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block

		}
		return null;
	}

	/**
	 * 生成产品
	 * @param vo
	 */
	public static void putPreBillMail(PreInstorageVo vo) {
		try {
			Single.PreBillMailQueue.put(vo);
		} catch (InterruptedException e) {

		}
	}

	/**
	 * 消费产品
	 * @return PreInstorageVo
	 */
	public static PreInstorageVo takePreBillMail() {
		try {
			return Single.PreBillMailQueue.take();
		} catch (InterruptedException e) {

		}
		return null;
	}

	public static void putInvoicePrinterQueue(InvoiceReturnModel model) {
		try {
			Single.InvoicePrinterQueue.put(model);
		} catch (InterruptedException e) {

		}
	}

	/**
	 * 消费产品
	 * @return PreInstorageVo
	 */
	public static InvoiceReturnModel takeInvoicePrinterModel() {
		try {
			return Single.InvoicePrinterQueue.take();
		} catch (InterruptedException e) {

		}
		return null;
	}

}
